﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// ConditionRecord 設計用來記錄每一個頁面最後的查詢紀錄
/// </summary>
[Serializable]
public class ConditionRecord
{
  public Dictionary<string, List<ControlItem>> PageItem = new Dictionary<string, List<ControlItem>>();
}

[Serializable]
public class ControlItem
{
  public ControlItem(string controlID, string controlValue, Type controlType)
  {
    ControlID = controlID;
    ControlValue = controlValue;
    ControlType = controlType;
  }

  public string ControlID { get; set; }
  public string ControlValue { get; set; }
  public Type ControlType { get; set; }
}

public class ConditionRecordUtil
{
  public static void RecordSearchConditionData(List<ControlItem> controlItem)
  {
    string pageUrl = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
    if (((ProfileCommon)HttpContext.Current.Profile).PageConditionRecord == null)
      ((ProfileCommon)HttpContext.Current.Profile).PageConditionRecord = new ConditionRecord();
    ((ProfileCommon)HttpContext.Current.Profile).PageConditionRecord.PageItem.Remove(pageUrl);
    ((ProfileCommon)HttpContext.Current.Profile).PageConditionRecord.PageItem.Add(pageUrl, controlItem);  
  }
}

